/*
 * @Author: 颜礼田 2564217790@qq.com
 * @Date: 2024-08-26 10:41:26
 * @LastEditors: MrDotYan 2564217790@qq.com
 * @LastEditTime: 2024-09-27 11:03:17
 * @FilePath: /webServerAdmin/src/api/modules/user.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import { PermissionSchema, UserSchema } from "@/schema";
import { ChangePwdInter, Id, ReqPage, ResPage } from "../interface";
export function saveUser(data: UserSchema) {
  return http.post<UserSchema>(`${PORT1}/user/save`, data);
}

export function fetchUserList(data: ReqPage) {
  return http.post<ResPage<Array<UserSchema>>>(`${PORT1}/user/list`, data);
}

export function fetchUserInfo(params: Id) {
  return http.get<UserSchema>(`${PORT1}/user/info`, params);
}

export function editUser(params: Id, data: Partial<UserSchema>) {
  return http.put<UserSchema>(`${PORT1}/user/edit`, data, { params });
}

export function removeUser(params: Id) {
  return http.delete<UserSchema>(`${PORT1}/user/remove`, params);
}

export function fetchUserPermissionListApi(params: Id) {
  return http.get<Array<PermissionSchema>>(`${PORT1}/user/permission`, params);
}

export function changePassword(params: Id, data: ChangePwdInter) {
  return http.put<UserSchema>(`${PORT1}/user/changePwd`, data, { params });
}
